package com.pigs.pigsordersystem.mapper;

import com.pigs.pigsordersystem.entity.InventoryEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;


/**
 * <p>
 * Mapper 接口
 * </p>
 * 库存 Mapper 接口
 *
 * @author Y.yang
 * @since 2020-03-14
 */
@Repository
public interface InventoryMapper extends BaseMapper<InventoryEntity> {

    /**
     * 购买成功就修改
     * *
     * * 库存数
     *
     * @param inventoryNum
     * @param productId
     * @return
     */
    @Update("update inventory set inventory_update_time=#{inventoryUpdateTime},inventory_num=inventory_num-#{inventoryNum} where product_id=#{productId}")
    public Integer updateInventoryNum(Integer inventoryNum, Integer productId, String inventoryUpdateTime);


}
